from sqlalchemy.orm import Session
from typing import Optional
from app.models.models import User
from app.database.repository.general_repository import GeneralRepository

class UserRepository(GeneralRepository[User]):
    """
    用户仓库类，处理用户相关的数据库操作
    """
    
    def __init__(self, db: Session):
        super().__init__(db, User)
    
    def find_by_name(self, name: str) -> Optional[User]:
        """
        根据用户名查找用户
        """
        return self.find_one(User.name == name)